package com.example.innovate.controller;

import com.example.innovate.bean.Result;
import com.example.innovate.domain.StarLevelDO;
import com.example.innovate.service.StarLevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/starLevel")
@Api(tags = "星级评价接口")
public class StarLevelController {
    @Autowired
    StarLevelService starLevelService;

    //@UserLoginToken
    @PostMapping("/addStarLevel")
    @ApiOperation("添加星级评价")
    public Result addStarLevel(@RequestBody StarLevelDO starLevelDO) throws Exception {
        starLevelService.addInfo(starLevelDO);
        return new Result(200, "success", "添加成功",starLevelDO);

    }

    //@UserLoginToken
    @GetMapping("/findStarLevel")
    @ApiOperation("查看星级评价")
    public Result findStarLevel(String modular,
                                @RequestParam("pageNumber") Integer pageNumber,
                                @RequestParam("pageSize") Integer pageSize) throws Exception {
        List<StarLevelDO> list = starLevelService.findAll(modular,pageNumber,pageSize);
        return new Result(200, "success", "返回成功", list);

    }

    //@UserLoginToken
    @PostMapping("/updateStarLevel")
    @ApiOperation("修改星级评价")
    public Result updateStarLevel(@RequestBody StarLevelDO starLevelDO) throws Exception {
        starLevelService.updateInfo(starLevelDO);
        return new Result(200, "success", "修改成功",starLevelDO);

    }

    //@UserLoginToken
    @DeleteMapping("/deleteStarLevel")
    @ApiOperation("删除星级评价")
    public Result deleteStarLevel(@RequestBody Integer deleteId) throws Exception {
        starLevelService.deleteInfo(deleteId);
        return new Result(200, "success", "删除成功","id="+deleteId);

    }



}
